import http from '@/utils/request'

const apiBefore = '/web/task-management'
const filesApiBefore = '/web'
const teamsApiBefore = '/web/um'

export const taskManager = {
  getUserMappingListApi: params => {
    return http.get(`${apiBefore}/sys/user-mapping/list-select`, { params })
  },
  putAutoMap: params => {
    return http.put(`${apiBefore}/sys/user-mapping/auto`, params)
  },
  getIntegrationNumberApi: params => {
    return http.get(`${apiBefore}/sys/user/integrationsUse`, { params })
  },
  getConnectorInfo: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/config`, { params })
  },
  getConnectorInfoNew: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/showIntegrations`, { params })
  },
  testPermission: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/status/permission`, params)
  },
  controlTdDataSync: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/onoff`, params)
  },
  controlTdGetOnOffStatusSync: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/getonoff`, params)
  },
  // Sync Data
  syncClientData: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/synchronise`, params)
  },
  getConnectorLogDetail: (params, config) => {
    return http.post(`${apiBefore}/sys/tenant/connector/logs/selectGrabLogDetail`, params, config)
  },
  getConnectorStatus: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/status/selectList`, params)
  },
  getCountGrabLogStatus: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/logs/countGrabLogStatus`, params)
  },
  getConnectorKey: params => {
    return http.get(`${apiBefore}/sys/dict/data/connect`, { params })
  },
  delConnectorKeyApi: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/delConfig`, { params })
  },
  // delete client
  deleteClient: params => {
    return http.post(`${apiBefore}/sys/tenant/delete`, params)
  },
  // SQL Agent
  postSQLFormAPI: params => {
    return http.post(`${apiBefore}/sql-agent/insert`, params)
  },
  updateSQLFormAPI: params => {
    return http.post(`${apiBefore}/sql-agent/update`, params)
  },
  getSQLListAPI: params => {
    return http.get(`${apiBefore}/sql-agent/list/${params.tenantCode}`, { params })
  },
  deleteSQLFormAPI: params => {
    return http.delete(`${apiBefore}/sql-agent/delete/${params.id}`, { params })
  },
  getSQLInfoAPI: params => {
    return http.get(`${apiBefore}/sql-agent/selectById/${params.id}`, { params })
  },
  getSQLDBInfoAPI: params => {
    return http.get(`${apiBefore}/sql-agent/getConfigInfo/${params.tenantCode}`, { params })
  },
  postClientData: params => {
    return http.post(`${apiBefore}/sys/tenant/connector/test`, params)
  },
  initIntegrations: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/status/reset`, { params })
  },
  alertIntegration: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/alertIntegration`, { params })
  },
  disablednonCwUser: params => {
    return http.get(`${apiBefore}/sys/user/disableUserNoCW`, { params })
  },
  disablednonAutotaskUserApi: params => {
    return http.get(`${apiBefore}/sys/user/disableUserNoAutoTask`, { params })
  },
  getConnectorData: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/apiInfo`, { params })
  },
  // webhook
  getWebhookListData: params => {
    return http.post(`${apiBefore}/at/webhook/getWebhookList`, params)
  },
  getWebhookDeatilData: params => {
    return http.post(`${apiBefore}/at/webhook/getWebhookDeatil`, params)
  },
  postStartAllWebhookSync: params => {
    return http.post(`${apiBefore}/at/webhook/create`, params)
  },
  postStartWebhookSync: params => {
    return http.post(`${apiBefore}/at/webhook/create/${params.entityType}`, params)
  },

  // files
  getUserListData: params => {
    return http.get(`${filesApiBefore}/dropbox-api/members/${params.tenantId}`, params)
  },
  getEchoData: params => {
    return http.get(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/get`, params)
  },
  getFileSearchResult: params => {
    return http.post(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/search/${params.team_member_id}`, params.body)
  },
  saveFiles: params => {
    return http.post(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/save`, params.body)
  },
  // personal files
  getPersonalFileSearchResult: params => {
    return http.post(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/search/personal`, params.body)
  },
  personalSaveFiles: params => {
    return http.post(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/save?type=${params.type}`, params.body)
  },
  getPersonalEchoData: params => {
    return http.get(`${filesApiBefore}/dropbox-api/files/${params.tenantId}/get?type=${params.type}`, params)
  },
  // remove integration feature
  deleteIntegrationConfigData: params => {
    return http.get(`${apiBefore}/sys/tenant/connector/delConfig`, { params })
  },
  // teams Permissions
  getDefaultScopeList: params => {
    return http.get(`${teamsApiBefore}/sys/dict/data/list?dictTypeId=1586916773799972865&dictValue=&dictType=team_scope`, { params })
  },
  getCustomizeScopeList: params => {
    return http.get(`${teamsApiBefore}/sys/dict/data/list?dictTypeId=1586919427297038338&dictValue=&dictType=team_scope_customize`, { params })
  },
  getSaveScope: params => {
    return http.get(`${apiBefore}/teams/scope/custom`, { params })
  },
  // oneDrive files
  getDriveData: params => {
    return http.get(`${filesApiBefore}/onedrive/drives/${params.tenantId}/drive?user=${params.user}`, params)
  },
  getSearchDriveFileData: params => {
    return http.get(`${filesApiBefore}/onedrive/drives/${params.tenantId}/search?query=${params.query}&driveId=${params.driveId}`, params)
  },
  saveFilesData: params => {
    return http.post(`${filesApiBefore}/onedrive/drives/${params.tenantId}/save`, params.body)
  },
  getFilesData: params => {
    return http.get(`${filesApiBefore}/onedrive/drives/${params.tenantId}/get`, params)
  },
  getLog:params => {
    return http.post(`${process.env.VUE_APP_SQL_AGENT_PREFIX}sql/sql-agent/getConnectLog`,params)
  },
  getDataset:params => {
    return http.get(`${process.env.VUE_APP_SQL_AGENT_PREFIX}sql/sql-agent/getDataset?integrationId=${params.integrationId}`)
  },
  //holidays
  holidayTree: ({ businessType }) => {
    return http.get(`${apiBefore}/sys/holiday/tree?businessType=${businessType}`)
  },
  holidayCopy: ({ templateId }) => {
    return http.get(`${apiBefore}/sys/holiday/${templateId}/copy`)
  },
  holidayList: (params) => {
    return http.get(`${apiBefore}/sys/holiday/items`, params)
  },
  holidayAdd: (params) => {
    return http.post(`${apiBefore}/sys/holiday/add`, params)
  },
  holidayDel: ({ id }) => {
    return http.delete(`${apiBefore}/sys/holiday/${id}/del`)
  },
  holidayUpdate: (params) => {
    return http.put(`${apiBefore}/sys/holiday/${params.id}/update`, params)
  },
  festivalValid: ({ id }) => {
    return http.get(`${apiBefore}/sys/festival/${id}/valid`)
  },
  festivalDel: ({ id }) => {
    return http.delete(`${apiBefore}/sys/festival/${id}/del`)
  },
  holidayValid: ({ id }) => {
    return http.get(`${apiBefore}/sys/holiday/${id}/valid`)
  },

}
